<?php
    //$this->Paginator->options(array('url' => array('ext' => false, '?' => $this->request->query)));
?>
<div id="content-header">
<h1><?php echo __d('system','Management List Term');?></h1>
</div>
<div id="breadcrumb">
    <a href="<?php echo $this->Html->url('/admin/')?>" title="Go to Home" class="tip-bottom"><i class="icon-home"></i> <?php echo __d('system','Home');?></a>
    <a href="#" class="current"><?php echo __d('system','List Term');?></a>
</div>
<div class="container-fluid">
<div class="row-fluid">
    <div class="span12">    
    <?php echo $this->element('toolbar');?>
    <?php echo $this->Form->create('Paginate', array('id' => 'paginate', 'url' => $this->request->here(false), 'type' => 'post', 'inputDefaults' => array('label' => false))); ?>                                            
        <div class="widget-box">
            <div class="widget-title">
                <span class="icon">
                    <i class="icon-th"></i>
                </span>
                <h5>List of content</h5>
            </div>
            <div class="widget-content widget-content-two">
                <div class="wd-select">
                    <div class="control-group">
                        <div class="controls wd-farming">
                            <select>
                                <option /><?php echo __d('system','Delete');?>
                            </select>
                            <button class="btn"><?php echo __d('system','Apply');?></button>
                        </div>
                    </div>
                </div>
                <table class="table table-bordered data-table table-striped with-check wd-hover-btn">
                    <thead>
                        <tr>
                            <th><input type="checkbox" id="title-table-checkbox" name="title-table-checkbox" /></th>
                            <th><?php echo  __d('system', 'Id'); ?>      </th>
                            <th> <?php echo  __d('system', 'Name'); ?></th>
                            <th> <?php echo  __d('system', 'Created'); ?></th>
                            <th>  <?php echo  __d('system', 'Updated'); ?></th>
                            <th class="wd-fix-width">  <?php echo  __d('system', 'Translate'); ?></th>
                            <th class="wd-fix-width"><?php echo  __d('system', 'Action'); ?></th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php
                        $defaultLanguage = Router::defaultLanguage();
                        $_queries = array('continue' => $this->request->here(false));
                        ?> 
                            <?php foreach ($listTerms as $term) : ?>                                            
                        <tr>
                        <td><input type="checkbox" name="data[Paginate][chk_term][]" value="<?php echo $term['Term']['id'];?>"/></td>            
                        <?php if (isset($_displayFields['id'])): ?>       
                            <td>
                                <?php echo $term['Term']['id']; ?>
                           </td>
                           <?php endif; ?>
                        <?php if (isset($_displayFields['name'])): ?>       
                           <td>
                                <?php echo $term['Term']['name']; ?>
                           </td>
                        <?php endif; ?>
                        <?php if (isset($_displayFields['created'])): ?>       
                            <td>
                                <?php echo date("d-m-Y",$term['Term']['created']); ?>
                           </td>
                        <?php endif; ?>
                        <?php if (isset($_displayFields['updated'])): ?>       
                            <td>
                                <?php echo date("d-m-Y",$term['Term']['updated']); ?>
                           </td>
                        <?php endif; ?>
                        <td>
                        <?php if (isset($_translateMaps)): ?>
                            <ul class="wd-laguage">
                                    <?php
                                    foreach (Configure::read('Languages') as $_language) {
                                        if ($_language['code'] === $defaultLanguage) {
                                            continue;
                                        } ?>
                                        <?php 
                                            if(empty($_language['path'])){
                                                $flags = 'flags_default.png';                                                
                                            }
                                            else{$flags = $_language['path'];}                                                                                        
                                        ?>
                            <li><?php  echo $this->Html->link($this->Html->image('/img/' .$flags), array('action' => 'translate', $term['Term']['id'], $_language['code'], '?' => $_queries), array(
                                    'class' => isset($_translateMaps[$term['Term']['id']][$_language['locale']]) ? '' : 'ui-state-disabled', 'escape' => false, 'title' => $_language['name']));?></li>           
                                    <?php }?>
                                    </ul>
                        <?php endif; ?>       
                        <td>
                            <ul class="wd-action">
                                <li> <?php echo $this->Html->link('Edit', array('action' => 'edit',$type_id, $term['Term']['id'], $term['Term']['parent_id'], '?' => $_queries), array('title' => __d('system', 'Edit'), 'class' => 'wd-edit')); ?></li>
                                <li><?php echo $this->Html->link('Delete', array('action' => 'delete', '?' => array_merge($_queries, array('keys' => array($term['Term']['id'])))), array('title' => __d('system', 'Delete this item'), 'class' => 'wd-delete'), __d('system', 'Are you sure to delete #%s ?', $term['Term']['id'])); ?></li>
                                <li> <?php echo $this->Html->link('Move up', array('action' => 'move', $term['Term']['id'], 'up', '?' => $_queries), array('title' => __d('system', 'Move up item'), 'class' => 'wd-up')); ?></li>
                                <li> <?php echo $this->Html->link('Move down', array('action' => 'move', $term['Term']['id'], 'down', '?' => $_queries), array('title' => __d('system', 'Move down item'), 'class' => 'wd-down')); ?></li>
                            </ul>
                        </td>
                        </tr>                        
           <?php endforeach?>                        
                    </tbody>                         
                </table>
               
                <div class="wd-select">
                    
                    <div class="control-group">
                        <div class="controls wd-farming">
                            <select>
                                <option /><?php echo __d('system','Delete');?>
                            </select>
                            <button class="btn"><?php echo __d('system','Apply');?></button>
                        </div>
                    </div>
                </div>                                
            </div>
        </div>
    </div>    
</div>
<?php         
echo $this->Form->hidden('task', array('id' => 'task', 'value' => ''));
echo $this->Form->end();
?>